;::::::::::::::::::::: ;: Load variables :: ;::::::::::::::::::::: ;: @op commands: ;: !cycle: Makes the bot /hop in the channel. ;: !info: Lists DJ connection info (required info to stream) ;: !kickdj: Kicks the current DJ. ;: ;: Regular commands: ;: !listeners: Displays listeners ;: !url/!listen/!tune: Displays a link to tune in ;: ;::::::::::::::::::::: on *:start: { set %cfg.url http://example.com ; Don't include a trailing / set %cfg.site example.com ; Same as above, without http:// set %cfg.name Example Radio ; Your SHOUTcast server name set %cfg.port 8000 ; port set %cfg.user admin ; admin panel username set %cfg.pass AdminPassword!@ ; admin panel password set %cfg.djpass DjPassword ; DJ password set %irc.chan #exampleradio ; Your IRC channel } ;:::::::::::::::: ;: Functions :: ;:::::::::::::::: on *:join:%irc.chan: { if ($nick == $me) { sc.con } } ;:::::::::::::::::::::: ;: Socket commands :: ;:::::::::::::::::::::: alias sc.con { if ($sock(sc).to == $null) { .timercon 0 10 sockopen sc %cfg.site %cfg.port } elseif ($sock(sc).to > 10) { sockclose sc | sockopen sc %cfg.site %cfg.port } } alias sc.kick { if ($sock(sc).to == $null) { sockopen sckick %cfg.site %cfg.port } elseif ($sock(sc).to > 10) { sockclose sc | sockopen sckick %cfg.site %cfg.port } } ;:::::::::::::::::::::::: ;: Function commands :: ;:::::::::::::::::::::::: alias errmsg { if ($1 == op) { notice $2 You must have @ (operator) status to use this. } elseif ($1 == offline) { notice $2 The stream is currently offline. } } alias sc.title { if ($1 == offline) { topic %irc.chan %cfg.name Nobody is currently DJ'ing. } else { topic %irc.chan %cfg.name DJ: %sc.dj $chr(124) Tune: %cfg.url } } alias sc.msg { msg %irc.chan %sc.dj is streaming %sc.song ( $+ %sc.bitrate $+ kbps) } ;:::::::::::::::::::::::: ;: Trigger functions :: ;:::::::::::::::::::::::: on *:text:!cycle:%irc.chan: { if ($nick isop %irc.chan) { hop %irc.chan } else { errmsg op $nick } } on *:text:!info:%irc.chan: { if ($nick isop %irc.chan) { notice $nick host: %cfg.site port: %cfg.port pass: %cfg.djpass | notice $nick description: %cfg.name url: %cfg.url aim: Make This Your DJ Name irc: %irc.chan } else { errmsg op $nick } } on *:text:!kickdj:%irc.chan: { if ($nick isop %irc.chan) { sc.kick | msg %irc.chan Kicking current DJ.. } else { errmsg op $nick } } on *:text:!listeners:%irc.chan: { if (%sc.status == 1) { notice $nick Listeners: %sc.clisten $+ / $+ %sc.mlisten } else { errmsg offline $nick } } on *:text:!tune:%irc.chan: { notice $nick Tune in at: %cfg.url $+ : $+ %cfg.port $+ /listen.pls } on *:text:!url:%irc.chan: { notice $nick Tune in at: %cfg.url $+ : $+ %cfg.port $+ /listen.pls } on *:text:!listen:%irc.chan: { notice $nick Tune in at: %cfg.url $+ : $+ %cfg.port $+ /listen.pls } ;::::::::::::::::::::::: ;: Socket functions :: ;::::::::::::::::::::::: on *:sockopen:sckick: { sockwrite -nt sckick GET /admin.cgi?mode=kicksrc HTTP/1.0 sockwrite -nt sckick User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.642.2 Safari/534.16 sockwrite -nt sckick Accept: text/xml,application/xml,application/xhtml+xml,text/html sockwrite -nt sckick Authorization: Basic $encode(%cfg.user $+ : $+ %cfg.pass, m) sockwrite -nt sckick $crlf } on *:sockread:sckick: { sockread -fn %tmp if (HTTP/1.0 302 Found isin %tmp) { msg %irc.chan DJ kicked. Go go go! } } on *:sockopen:sc: { sockwrite -nt sc GET /admin.cgi?mode=viewxml HTTP/1.0 sockwrite -nt sc User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.642.2 Safari/534.16 sockwrite -nt sc Accept: text/xml,application/xml,application/xhtml+xml,text/html sockwrite -nt sc Authorization: Basic $encode(%cfg.user $+ : $+ %cfg.pass, m) sockwrite -nt sc $crlf } on *:sockread:sc: { sockread -fn %tmp if (, $chr(189), , $chr(189)) | var %tmp $gettok(%tmp, 2, 189) ;; Filter bad characters var %tmp $replace(%tmp, $chr(38) $+ $chr(35) $+ x27 $+ $chr(59), $chr(39), $chr(38) $+ $chr(35) $+ x26 $+ $chr(59), $chr(38), $chr(38) $+ amp $+ $chr(59), $chr(38)) ;; %sc.status var %sc $replace(%tmp, , $chr(189), , $chr(189)) | set %sc.status $gettok(%sc, 2, 189) if (%sc.status == 0 && %sc.statuslock != 1) { set %sc.statuslock 1 | unset %sc.dj | set %sc.dj.old qwerty!!! | unset %sc.song | set %sc.song.old qwerty!!! | sc.title offline | HALT } elseif (%sc.status == 0 && %sc.statuslock == 1) { HALT } ;; %sc.clisten var %sc $replace(%tmp, , $chr(189), , $chr(189)) | set %sc.clisten $gettok(%sc, 1, 189) ;; %sc.rlisten var %sc $replace(%tmp, , $chr(189), , $chr(189)) | set %sc.rlisten $gettok(%sc, 2, 189) ;; %sc.plisten var %sc $replace(%tmp, , $chr(189), , $chr(189)) | set %sc.plisten $gettok(%sc, 2, 189) ;; %sc.mlisten var %sc $replace(%tmp, , $chr(189), , $chr(189)) | set %sc.mlisten $gettok(%sc, 2, 189) ;; %sc.alisten var %sc $replace(%tmp, , $chr(189), , $chr(189)) | set %sc.alisten $duration($gettok(%sc, 2, 189)) ;; %sc.genre var %sc $replace(%tmp, , $chr(189), , $chr(189)) | set %sc.genre $gettok(%sc, 2, 189) ;; %sc.bitrate var %sc $replace(%tmp, , $chr(189), , $chr(189)) | set %sc.bitrate $gettok(%sc, 2, 189) ;; %sc.dj $iif(%sc.dj, set %sc.dj.old %sc.dj) var %sc $replace(%tmp, , $chr(189), , $chr(189)) | set %sc.dj $gettok(%sc, 2, 189) if (%sc.dj != %sc.dj.old) { sc.title %sc.dj | set %sc.statuslock 0 } ;; %sc.song $iif(%sc.song, set %sc.song.old %sc.song) var %sc $replace(%tmp, , $chr(189), , $chr(189)) | set %sc.song $gettok(%sc, 2, 189) if (%sc.song != %sc.song.old) { sc.msg %sc.song } }